package ar.com.jwa.commons.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import ar.com.jwa.domain.User;

public class LoginValidator implements Validator {

    public boolean supports(Class candidate) {
        return User.class.isAssignableFrom(candidate);
    }

    public void validate(Object obj, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "required", "Email is required.");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "required", "Password is required.");
    }
}